<?php
allowCors();
if (!methodsRequired(['get'])) return;
if (!checkAdmin($msg)) return;

if (isset($_REQUEST['dept_id'])) {
    $dept = new Department();
    $dept->setDeptId($_REQUEST['dept_id']);
    $newData = [];
    if (isset($_REQUEST['dept_name']))
        $newData['dept_name'] = $_REQUEST['dept_name'];
    if (isset($_REQUEST['info']))
        $newData['dept_info'] = $_REQUEST['dept_info'];
    if (isset($_REQUEST['dept_manage_id']))
        $newData['dept_manage_id'] = $_REQUEST['dept_manage_id'];
    if ($db->edit($dept,$newData)) {
        $msg->setCode(0);
    } else {
        $msg->setCode(3);
    }
} else {
    $msg->setCode(3);
}
echo $msg;